﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ElectronicSelling.UserControl
{
    public partial class Header : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                txtSearch.Attributes.Add("onkeypress", "return textboxKeyDown(event,'" + btnSearch.ClientID + "')");
            }
        }

        public int NumberOfCartItem()
        {
            if (Session["cart"] != null)
            {
                DataTable dt = Session["cart"] as DataTable;
                return dt.Rows.Count;
            }
            else
                return 0;

        }

        protected void lnkLogout_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("Default.aspx");
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            Session["SearchValue"] = txtSearch.Text;
            Response.Redirect("ProductList.aspx?action=search");
        }

        
    }
}